package com.kcht.sylyg08.ctrl;

import com.kcht.adp.common.Session;
import com.kcht.adp.common.log.Logger;
import com.kcht.adp.pagination.Page;
import com.kcht.adp.web.rs.AdpRest;
import com.kcht.sylyg08.ctrl.vo.TaskVO;
import com.kcht.sylyg08.service.TaskService;
import com.kcth.sylyg08.entity.Task;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.QueryParam;

@RequestScoped
@Transactional(Transactional.TxType.NOT_SUPPORTED)
public class TaskCtrl {
    @Inject
    private Logger logger;
    @Inject
    private TaskService taskService;
    @Inject
    private Session session;

    @AdpRest(principal = "任务列表", permission = "任务列表")
    public Page<Task, TaskVO> list(Page<Task, TaskVO> page) {
        return taskService.list(page);
    }

    /*@AdpRest()
    public Page<Task, TaskVO> listErrorTask(Page<Task, TaskVO> page) {
        return taskService.listErrorTask(page);
    }*/

    @AdpRest(principal = "处理异常任务", permission = "处理异常任务")
    public String confirmErrorTask(@QueryParam("id") Long id, @QueryParam("details") String details, @QueryParam("containerIds") String containers) {
        return taskService.confirmErrorTask(id, session.getUser().getRealName(), details, containers);
    }
}
